﻿Shader "Dan/2D/Dust2D"
{
    Properties
    {
        [HDR]_Color ("Tint Color", Color) = (0.9,0.2,0.1,1)
        _Speed("Speed",Range(0,5))=3.5
        _MaskVal("Mask Val",Range(0,1))=0.8
        _DustSize("Dust Size",Range(0,1))=0.2
        _Layer("Layer",Int)=3
    }
    SubShader
    {
        Tags { "RenderType"="Transparent" "Queue"= "Transparent" "IgnoreProjector"="True"}
        LOD 100

        Pass
        {
            
            Blend SrcAlpha OneMinusSrcAlpha
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            

            #include "UnityCG.cginc" 
            #include "../ShaderLibs/Feature.cginc"
            struct appdata
            {
                float4 vertex : POSITION;
                float2 uv : TEXCOORD0;
            };

            struct v2f
            {
                float2 uv : TEXCOORD0;
               
                float4 vertex : SV_POSITION;
            };

            
            float4 _Color;
            float _MaskVal;
            float _DustSize;
            float _Speed;
            float _Layer;

            v2f vert (appdata v)
            {
                v2f o;
                o.vertex = UnityObjectToClipPos(v.vertex);
                o.uv = v.uv;
                
                return o;
            }


            

            fixed4 frag (v2f i) : SV_Target
            {
                
                float2 uv = i.uv;
            
                float mask=0;
                
                for (int i = 0; i < _Layer; ++i)
                {
                     mask+=DrawDust(uv,i,_Speed,_MaskVal,_DustSize);
                }
                
                
               
                return mask*_Color;
            }
            ENDCG
        }
    }
}
